<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/19
 * Time: 17:52
 */
namespace Admin\Controller;
use Admin\Model\BaseinfoVersionModel;
use Base\Controller\CurdController;
 class  DailyitemtypeController extends CurdController{
     public function __construct()
     {
         parent::__construct();
     }
     /**
      * 获取所有数据并注入模板
      * */
     protected function getAll()
     {
         if($_REQUEST['keyword']){
             $map['typename'] = array('like','%'.$_REQUEST['keyword'].'%');
             $map['_logic'] = 'or';
             $where['_complex'] = $map;
         }
         if($_REQUEST['selects']){
             $limit=$_REQUEST['selects'];
         }else{
             $limit=20;
         }
         if(!I('get.del')){
             $where['status']=1;
         }else{
             $where['status']=0;
         }
         $data = $this->model->pageToView($limit, true,$where);
         $this->assign("page", $data['page']);
         $this->assign("list", $data['list']);
     }
     protected function addAfter($data)
     {
         $BaseinfoVersionModel=new BaseinfoVersionModel();
         $controller = hump2underline(CONTROLLER_NAME);
         $infos=$BaseinfoVersionModel->where(array('name'=>$controller))->find();
         $data['version']=$infos['version'];
         $ids=$this->model->order('id desc')->find();
         $data['id']=$ids['id']+1;
         return $data;
     }
     protected function editAfter($data)
     {
         $BaseinfoVersionModel=new BaseinfoVersionModel();
         $controller = hump2underline(CONTROLLER_NAME);
         $infos=$BaseinfoVersionModel->where(array('name'=>$controller))->find();
         $data['version']=$infos['version'];
         return $data;
     }
 }